package json_util

import (
	"encoding/json"
	"github.com/pkg/errors"
	"trpg-common/logger"
)

func Marshal(v interface{}) []byte {
	bytes, err := json.Marshal(v)
	if err != nil {
		logger.Logger.Panicf("%+v", errors.Wrap(err, "error in marshal json"))
	}
	return bytes
}

func UnMarshal(bytes []byte, v interface{}) {
	err := json.Unmarshal(bytes, v)
	if err != nil {
		logger.Logger.Panicf("%+v", errors.Wrap(err, "error in marshal json"))
	}
}
